package com.alan.wlmediaplayer.utils;

/**
 * @author Alan
 * 时 间：11/2/21
 * 简 述：<功能简述>
 */
public class WlSetting {

    private static WlSetting setting;

    private int channelIndex;
    private int screenSizeIndex;
    private int speedIndex;
    private int playModeIndex;
    private int playColorIndex;

    public String[] channelData;
    public String[] screenData = new String[]{"原始尺寸", "16:9", "4:3"};
    public String[] speedData = new String[]{"0.5倍", "1倍", "1.5倍", "2倍"};
    public String[] modeData = new String[]{"正常播放", "仅播放视频", "仅播放声音"};
    public String[] colorData = new String[]{"彩色", "黑白", "反色"};

    private OnWlMediaSettingChangedListener onWlMediaSettingChangedListener;

    private WlSetting() {
        reset();
    }

    public static WlSetting getInstance() {
        if (null == setting) {
            setting = new WlSetting();
        }
        return setting;
    }

    public void reset() {
        channelIndex = 0;
        screenSizeIndex = 0;
        speedIndex = 1;
        playModeIndex = 0;
        playColorIndex = 0;
        channelData = new String[]{"默认"};
    }

    public WlSetting setChannelData(String[] channelData) {
        this.channelData = channelData;
        return this;
    }

    public OnWlMediaSettingChangedListener getOnWlMediaSettingChangedListener() {
        return onWlMediaSettingChangedListener;
    }

    public WlSetting setOnWlMediaSettingChangedListener(OnWlMediaSettingChangedListener onWlMediaSettingChangedListener) {
        this.onWlMediaSettingChangedListener = onWlMediaSettingChangedListener;
        return this;
    }

    public WlSetting setChannelIndex(int channelIndex) {
        this.channelIndex = channelIndex;
        if (null != onWlMediaSettingChangedListener) {
            onWlMediaSettingChangedListener.onChannelChangedListener(channelIndex);
        }
        return this;
    }

    public WlSetting setScreenSizeIndex(int screenSizeIndex) {
        this.screenSizeIndex = screenSizeIndex;
        if (null != onWlMediaSettingChangedListener) {
            onWlMediaSettingChangedListener.onScreenSizeChangedListener(screenSizeIndex);
        }
        return this;
    }

    public WlSetting setSpeedIndex(int speedIndex) {
        this.speedIndex = speedIndex;
        if (null != onWlMediaSettingChangedListener) {
            onWlMediaSettingChangedListener.onSpeedChangedListener(speedIndex);
        }
        return this;
    }

    public WlSetting setPlayModeIndex(int playModeIndex) {
        this.playModeIndex = playModeIndex;
        if (null != onWlMediaSettingChangedListener) {
            onWlMediaSettingChangedListener.onPlayModeChangedListener(playModeIndex);
        }
        return this;
    }

    public WlSetting setPlayColorIndex(int playColorIndex) {
        this.playColorIndex = playColorIndex;
        if (null != onWlMediaSettingChangedListener) {
            onWlMediaSettingChangedListener.onPlayColorChangedListener(playColorIndex);
        }
        return this;
    }

    public int getChannelIndex() {
        return channelIndex;
    }

    public int getScreenSizeIndex() {
        return screenSizeIndex;
    }

    public int getSpeedIndex() {
        return speedIndex;
    }

    public int getPlayModeIndex() {
        return playModeIndex;
    }

    public int getPlayColorIndex() {
        return playColorIndex;
    }

    public interface OnWlMediaSettingChangedListener {
        void onChannelChangedListener(int index);

        void onScreenSizeChangedListener(int index);

        void onSpeedChangedListener(int index);

        void onPlayModeChangedListener(int index);

        void onPlayColorChangedListener(int index);
    }

    public void release() {
        onWlMediaSettingChangedListener = null;
    }
}
